#root {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
}

/* Override Ant Design styles for better layout */
.ant-layout {
  background: #fff;
}

.ant-layout-header {
  background: #1677ff;
  padding: 0 16px;
  height: 56px;
  line-height: 56px;
}

.ant-layout-sider {
  border-right: 1px solid #f0f0f0;
}

.ant-tabs-nav {
  margin-bottom: 0 !important;
}

/* 深色模式下的Tabs样式 */
.ant-layout-content .ant-tabs-tab {
  color: inherit;
}

.dark-mode .ant-tabs-tab {
  color: rgba(255, 255, 255, 0.85) !important;
}

.dark-mode .ant-tabs-tab:hover {
  color: #1677ff !important;
}

.dark-mode .ant-tabs-tab-active .ant-tabs-tab-btn {
  color: #1677ff !important;
}

.dark-mode .ant-tabs-ink-bar {
  background: #1677ff !important;
}

/* Markdown preview styles */
.markdown-preview h1 {
  font-size: 28px;
  margin-bottom: 16px;
}

.markdown-preview h2 {
  font-size: 24px;
  margin-bottom: 14px;
}

.markdown-preview h3 {
  font-size: 20px;
  margin-bottom: 12px;
}

.markdown-preview p {
  margin-bottom: 16px;
  line-height: 1.6;
}

.markdown-preview ul, .markdown-preview ol {
  padding-left: 24px;
  margin-bottom: 16px;
}

.markdown-preview li {
  margin-bottom: 8px;
}

/* 确保内联代码样式一致，不受代码主题影响 */
.markdown-preview code:not(pre code) {
  background-color: #f5f5f5;
  padding: 2px 4px;
  border-radius: 3px;
  font-family: 'Courier New', Courier, monospace;
  color: #333;
}

.dark-mode .markdown-preview code:not(pre code) {
  background-color: #2a2a2a;
  color: #f0f0f0;
}

.markdown-preview pre {
  background-color: #f5f5f5;
  padding: 16px;
  border-radius: 6px;
  overflow: auto;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  position: relative;
  font-family: 'Fira Code', 'Consolas', 'Monaco', 'Andale Mono', 'Ubuntu Mono', monospace;
  line-height: 1.5;
  padding-top: 30px; /* 为顶部栏留出空间 */
}

/* 添加代码块顶部栏，模拟编辑器界面 */
.markdown-preview pre::before {
  content: '';
  height: 12px;
  width: 12px;
  background: #ff5f56;
  border-radius: 50%;
  position: absolute;
  top: 8px;
  left: 8px;
  box-shadow: 20px 0 0 #ffbd2e, 40px 0 0 #27c93f;
}

/* 为代码块添加复制按钮 */
.markdown-preview pre .copy-button {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: #999;
  border: none;
  border-radius: 3px;
  padding: 2px 8px;
  font-size: 12px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, background-color 0.2s;
  z-index: 10;
}

.markdown-preview pre:hover .copy-button {
  opacity: 1;
}

.markdown-preview pre .copy-button:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #666;
}

.dark-mode .markdown-preview pre .copy-button {
  background: rgba(255, 255, 255, 0.1);
  color: #ccc;
}

.dark-mode .markdown-preview pre .copy-button:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

/* 为代码块添加语言标识 */
.markdown-preview pre::after {
  content: attr(data-language);
  position: absolute;
  top: 8px;
  right: 70px; /* 为复制按钮留出空间 */
  font-size: 12px;
  color: #999;
  background: rgba(0, 0, 0, 0.07);
  padding: 2px 6px;
  border-radius: 3px;
  text-transform: uppercase;
}

/* 为特定语言的代码块添加标识 */
.markdown-preview pre.language-javascript::after {
  content: 'javascript';
}

.markdown-preview pre.language-js::after {
  content: 'js';
}

.markdown-preview pre.language-typescript::after,
.markdown-preview pre.language-ts::after {
  content: 'ts';
}

.markdown-preview pre.language-html::after {
  content: 'html';
}

.markdown-preview pre.language-css::after {
  content: 'css';
}

.markdown-preview pre.language-python::after {
  content: 'python';
}

.markdown-preview pre.language-java::after {
  content: 'java';
}

.markdown-preview pre.language-c::after {
  content: 'c';
}

.markdown-preview pre.language-cpp::after {
  content: 'c++';
}

.markdown-preview pre.language-go::after {
  content: 'go';
}

.markdown-preview pre.language-rust::after {
  content: 'rust';
}

.markdown-preview pre.language-swift::after {
  content: 'swift';
}

.markdown-preview pre.language-php::after {
  content: 'php';
}

.markdown-preview pre.language-ruby::after {
  content: 'ruby';
}

.markdown-preview pre.language-shell::after,
.markdown-preview pre.language-bash::after {
  content: 'shell';
}

.markdown-preview pre.language-sql::after {
  content: 'sql';
}

.markdown-preview pre.language-json::after {
  content: 'json';
}

.markdown-preview pre.language-xml::after {
  content: 'xml';
}

.markdown-preview pre.language-yaml::after {
  content: 'yaml';
}

.markdown-preview pre.language-markdown::after,
.markdown-preview pre.language-md::after {
  content: 'markdown';
}

/* 为代码块添加顶部空间，容纳模拟的编辑器按钮 */
.markdown-preview pre code {
  background-color: transparent;
  padding: 0;
  border-radius: 0;
  display: block;
  /* 代码块内的代码颜色由代码主题决定 */
  font-size: 14px;
  tab-size: 2;
  counter-reset: line;
}

/* 添加行号 */
.markdown-preview pre code > span {
  display: block;
  position: relative;
  padding-left: 1.5em;
  min-height: 1.5em;
}

.markdown-preview pre code > span::before {
  counter-increment: line;
  content: counter(line);
  position: absolute;
  left: 0;
  color: #999;
  text-align: right;
  width: 1em;
  font-size: 0.8em;
  opacity: 0.5;
}

.dark-mode .markdown-preview pre {
  background-color: #2a2a2a;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.dark-mode .markdown-preview pre::after {
  background: rgba(255, 255, 255, 0.1);
  color: #ccc;
}

.markdown-preview blockquote {
  border-left: 4px solid #ddd;
  padding-left: 16px;
  color: #666;
  margin-bottom: 16px;
}

.markdown-preview img {
  max-width: 100%;
  height: auto;
}

/* Platform-specific preview styles */
.xiaohongshu-preview {
  font-family: 'PingFang SC', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

.wechat-preview {
  font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
  color: #333;
}

.zhihu-preview {
  font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

.toutiao-preview {
  font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
}

.nowcoder-preview {
  font-family: 'PingFang SC', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

/* Dark mode styles */
.dark-mode .markdown-preview {
  color: #f0f0f0;
  background-color: #1f1f1f;
}

.dark-mode .markdown-preview code {
  background-color: #2a2a2a;
}

.dark-mode .markdown-preview pre {
  background-color: #2a2a2a;
}

.dark-mode .markdown-preview blockquote {
  border-left-color: #444;
  color: #aaa;
}
